Modifying run-time-instrumentation controls from a lesser-privileged state

ABSTRACT

Embodiments of the invention relate to modifying run-time-instrumentation controls (MRIC) from a lesser-privileged state. The MRIC instruction is fetched. The MRIC instruction includes the address of a run-time-instrumentation control block (RICCB). The RICCB is fetched based on the address included in the MRIC instruction. The RICCB includes values for modifying a subset of the processor&#39;s run-time-instrumentation controls. The subset of run-time-instrumentation controls includes a runtime instrumentation program buffer current address (RCA) of a runtime instrumentation program buffer (RIB) location. The RIB holds run-time-instrumentation information of the events recognized by the processor during program execution. The values of the RICCB are loaded into the run-time-instrumentation controls. Event information is provided to the RIB based on the values that were loaded in the run-time-instrumentation control.

BACKGROUND

The present invention relates generally to processing within a computingenvironment, and more specifically, to modifyingrun-time-instrumentation controls from a lesser-privileged state.

Computer processors execute programs, or instruction streams usingincreasingly complex branch prediction and instruction caching logic.These processes have been introduced to increase instruction throughput,and therefore processing performance. The introduction of logic forimproving performance makes it difficult to predict with certainty how aparticular software application will execute on the computer processor.During the software development process there is often a balance betweenfunctionality and performance. Software is executed at one or morelevels of abstraction from the underlying hardware that is executing thesoftware. When hardware is virtualized, an additional layer ofabstraction is introduced. With the introduction of performanceenhancing logic, and the various layers of abstraction it is difficultto have a thorough understanding of what is actually occurring at thehardware level when a program is executing. Without this information,software developers use more abstract methods, such as executionduration, memory usage, number of threads, etc., for optimizing thesoftware application.

When hardware specific information is available, it is typicallyprovided to a developer after the fact and it is provided in aggregate,at a high level, and/or interspersed with the activity of otherprograms, and the operating system, making it difficult to identifyissues that may be impacting the efficiency and accuracy of the softwareapplication.

SUMMARY

Embodiments include a method, system, and computer program product formodifying run-time-instrumentation controls (MRIC) from alesser-privileged state. The MRIC instruction is fetched. The MRICinstruction includes the address of a run-time-instrumentation controlblock (RICCB). The RICCB is fetched based on the address included in theMRIC instruction. The RICCB includes values for modifying a subset ofthe processor's run-time-instrumentation controls. The subset ofrun-time-instrumentation controls includes a runtime instrumentationprogram buffer current address (RCA) of a runtime instrumentationprogram buffer (RIB) location. The RIB holds run-time-instrumentationinformation of the events recognized by the processor during programexecution. The values of the RICCB are loaded into therun-time-instrumentation controls. Event information is provided to theRIB based on the values that were loaded in the run-time-instrumentationcontrol.

Additional features and advantages are realized through the techniquesof the present invention. Other embodiments and aspects of the inventionare described in detail herein and are considered a part of the claimedinvention. For a better understanding of the invention with advantagesand features, refer to the description and to the drawings.

BRIEF DESCRIPTION OF THE SEVERAL VIEWS OF THE DRAWINGS

The subject matter which is regarded as the invention is particularlypointed out and distinctly claimed in the claims at the conclusion ofthe specification. The forgoing and other features, and advantages ofthe invention are apparent from the following detailed description takenin conjunction with the accompanying drawings in which:

FIG. 1A is a diagram depicting an example host computer system in anembodiment;

FIG. 1B is a diagram depicting an example emulation host computer systemin an embodiment;

FIG. 1C is a diagram depicting an example computer system in anembodiment;

FIG. 2 is a diagram depicting an example computer network in anembodiment;

FIG. 3 is a diagram depicting an elements of a computer system in anembodiment;

FIGS. 4A-4C depict detailed elements of a computer system in anembodiment;

FIG. 5 depicts a schematic diagram of a system forrun-time-instrumentation of a processor in accordance with anembodiment;

FIG. 6 depicts a modify run-time-instrumentation controls (MRIC)instruction in an embodiment;

FIG. 7 depicts a process flow for initiating an MRIC instruction from alesser-privileged state program in an embodiment;

FIG. 8 depicts a process flow for initiating an MRIC instruction from alesser-privileged state program in an additional embodiment;

FIG. 9 depicts a portion of a run-time-instrumentation controls controlblock (RICCB) including controls that are settable by a privileged statein an embodiment;

FIG. 10 depicts a portion of an RICCB control block when thesemi-privileged bit (K) is set to 1 in an embodiment;

FIG. 11 depicts a portion of an RICCB control block when thesemi-privileged bit (K) is set to 0 in an embodiment;

FIG. 12 depicts a reporting group in accordance with an embodiment; and

FIG. 13 illustrates a computer program product in an embodiment.

DETAILED DESCRIPTION

An embodiment of the present invention is a system, method and computerprogram product for updating a subset of run-time-instrumentationcontrols from a lesser-privileged state. In an embodiment, alesser-privileged state program is allowed to modify most or all of therun-time-instrumentation controls based on the validity of the currentrun-time-instrumentation controls, the current state of therun-time-instrumentation controls, and based on a flag (K) indicatingthat lesser-privileged state configuration is allowed. Thelesser-privileged state program executes a modifyrun-time-instrumentation controls (MRIC) instruction to update therun-time-instrumentation controls. Although the MRIC instruction allowsthe update of a large number of run-time-instrumentation controls, basedon the permission settings of the run-time-instrumentation controls,most of the run-time-instrumentation controls may be updated by thelesser privileged state program using the MRIC instruction.

FIG. 1A, depicts the representative components of a host computer system50 in an embodiment. Other arrangements of components may also beemployed in a computer system. The representative host computer system50 comprises one or more processors 1 in communication with main store(computer memory) 2 as well as I/O interfaces to storage devices 11 andnetworks 10 for communicating with other computers or SANs and the like.The processor 1 is compliant with an architecture having an architectedinstruction set and architected functionality. The processor 1 may havedynamic address translation (DAT) 3 for transforming program addresses(virtual addresses) into a real address in memory. A DAT 3 typicallyincludes a translation lookaside buffer (TLB) 7 for caching translationsso that later accesses to the block of computer memory 2 do not requirethe delay of address translation. Typically a cache 9 is employedbetween the computer memory 2 and the processor 1. The cache 9 may behierarchical having a large cache available to more than one CPU andsmaller, faster (lower level) caches between the large cache and eachCPU. In some embodiments, the lower level caches are split to provideseparate low level caches for instruction fetching and data accesses. Inan embodiment, an instruction is fetched from the computer memory 2 byan instruction fetch unit 4 via the cache 9. The instruction is decodedin an instruction decode unit 6 and dispatched (with other instructionsin some embodiments) to instruction execution units 8. Typically severalinstruction execution units 8 are employed, for example an arithmeticexecution unit, a floating point execution unit and a branch instructionexecution unit. The instruction is executed by the instruction executionunit 8, accessing operands from instruction specified registers or thecomputer memory 2 as needed. If an operand is to be accessed (loaded orstored) from the computer memory 2, the load store unit 5 typicallyhandles the access under control of the instruction being executed.Instructions may be executed in hardware circuits or in internalmicrocode (firmware) or by a combination of both.

In FIG. 1B, depicts an emulated host computer system 21 is provided thatemulates a host computer system of a host architecture, such as the hostcomputer system 50 of FIG. 1. In the emulated host computer system 21, ahost processor (CPU) 1 is an emulated host processor (or virtual hostprocessor) 29, and comprises a native processor 27 having a differentnative instruction set architecture than that of the processor 1 of thehost computer system 50. The emulated host computer system 21 has memory22 accessible to the native processor 27. In an embodiment, the memory22 is partitioned into a computer memory 2 portion and an emulationroutines memory 23 portion. The computer memory 2 is available toprograms of the emulated host computer system 21 according to the hostcomputer architecture. The native processor 27 executes nativeinstructions of an architected instruction set of an architecture otherthan that of the emulated processor 29, the native instructions obtainedfrom the emulation routines memory 23, and may access a host instructionfor execution from a program in the computer memory 2 by employing oneor more instruction(s) obtained in a sequence & access/decode routinewhich may decode the host instruction(s) accessed to determine a nativeinstruction execution routine for emulating the function of the hostinstruction accessed. Other facilities that are defined for the hostcomputer system 50 architecture may be emulated by architectedfacilities routines, including such facilities as general purposeregisters, control registers, dynamic address translation andinput/output (I/O) subsystem support and processor cache for example.The emulation routines may also take advantage of function available inthe native processor 27 (such as general registers and dynamictranslation of virtual addresses) to improve performance of theemulation routines. Special hardware and off-load engines may also beprovided to assist the native processor 27 in emulating the function ofthe host computer system 50.

In a mainframe, architected machine instructions are used byprogrammers, usually today “C” programmers often by way of a compilerapplication. These instructions stored in the storage medium may beexecuted natively in a z/Architecture IBM Server, or alternatively inmachines executing other architectures. They can be emulated in theexisting and in future IBM mainframe servers and on other machines ofIBM (e.g. pSeries® Servers and xSeries® Servers). They can be executedin machines running Linux on a wide variety of machines using hardwaremanufactured by IBM®, Intel®, AMD™, Sun Microsystems and others. Besidesexecution on that hardware under a Z/Architecture®, Linux can be used aswell as machines which use emulation by Hercules, UMX, FundamentalSoftware, Inc. (FSI) or Platform Solutions, Inc. (PSI), where generallyexecution is in an emulation mode. In emulation mode, emulation softwareis executed by a native processor to emulate the architecture of anemulated processor.

One or more of the components of the emulated host computer system 21are further described in “IBM® z/Architecture Principles of Operation,”Publication No. SA22-7932-08, 9th Edition, August, 2010 which is herebyincorporated herein by reference in its entirety. IBM is a registeredtrademark of International Business Machines Corporation, Armonk, N.Y.,USA. Other names used herein may be registered trademarks, trademarks orproduct names of International Business Machines Corporation or othercompanies.

The native processor 27 typically executes emulation software stored inthe emulation routines memory 23 comprising either firmware or a nativeoperating system to perform emulation of the emulated processor. Theemulation software is responsible for fetching and executinginstructions of the emulated processor architecture. The emulationsoftware maintains an emulated program counter to keep track ofinstruction boundaries. The emulation software may fetch one or moreemulated machine instructions at a time and convert the one or moreemulated machine instructions to a corresponding group of native machineinstructions for execution by the native processor 27. These convertedinstructions may be cached such that a faster conversion can beaccomplished. The emulation software maintains the architecture rules ofthe emulated processor architecture so as to assure operating systemsand applications written for the emulated processor operate correctly.Furthermore the emulation software provides resources identified by theemulated processor architecture including, but not limited to controlregisters, general purpose registers, floating point registers, dynamicaddress translation function including segment tables and page tablesfor example, interrupt mechanisms, context switch mechanisms, time ofday (TOD) clocks and architected interfaces to I/O subsystems such thatan operating system or an application program designed to run on theemulated processor 29, can be run on the native processor 27 having theemulation software.

A specific instruction being emulated is decoded, and a subroutinecalled to perform the function of the individual instruction. Anemulation software function emulating a function of an emulatedprocessor 29 is implemented, for example, in a “C” subroutine or driver,or some other method of providing a driver for the specific hardware aswill be within the skill of those in the art after understanding thedescription of the preferred embodiment.

In an embodiment, the invention may be practiced by software (sometimesreferred to licensed internal code, firmware, micro-code, milli-code,pico-code and the like, any of which would be consistent with thepresent invention). Referring to FIG. 1A, software program code whichembodies the present invention is accessed by the processor also knownas a CPU (Central Processing Unit) 1 of the host computer system 50 fromthe storage device 11 such as a long-term storage media, a CD-ROM drive,tape drive or hard drive. The software program code may be embodied onany of a variety of known media for use with a data processing system,such as a diskette, hard drive, or CD-ROM. The code may be distributedon such media, or may be distributed to users from the computer memory 2or storage of one computer system over a network 10 to other computersystems for use by users of such other systems.

Alternatively, the program code may be embodied in the computer memory2, and accessed by the processor 1 using a processor bus (not shown).Such program code includes an operating system which controls thefunction and interaction of the various computer components and one ormore application programs. Program code is normally paged from a densemedia such as the storage device 11 to computer memory 2 where it isavailable for processing by the processor 1. The techniques and methodsfor embodying software program code in memory, on physical media, and/ordistributing software code via networks are well known and will not befurther discussed herein. Program code, when created and stored on atangible medium (including but not limited to electronic memory modules(RAM), flash memory, compact discs (CDs), DVDs, Magnetic Tape and thelike is often referred to as a “computer program product.” The computerprogram product medium is typically readable by a processing circuitpreferably in a computer system for execution by the processing circuit.

FIG. 1C illustrates a representative workstation or server hardwaresystem in which the present invention may be practiced. The system 100of FIG. 1C comprises a representative base computer system 101, such asa personal computer, a workstation or a server, including optionalperipheral devices. The base computer system 101 includes one or moreprocessors 106 and a bus (not shown) employed to connect and enablecommunication between the one or more processors 106 and the othercomponents of the base computer system 101 in accordance with knowntechniques. The bus connects the processor 106 to memory 105 andlong-term storage 107 which may include a hard drive (including any ofmagnetic media, CD, DVD and Flash Memory for example) or a tape drivefor example. The base computer system 101 may also include a userinterface adapter, which connects the one or more processors 106 via thebus to one or more interface devices, such as a keyboard 104, a mouse103, a printer/scanner 110 and/or other interface devices, which may beany user interface device, such as a touch sensitive screen, digitizedentry pad, etc. The bus also connects the one or more processors to adisplay device 102, such as an LCD screen or monitor via a displayadapter.

The base computer system 101 may communicate with other computers ornetworks of computers by way of a network adapter capable ofcommunicating 108 with a network 109. Example network adapters arecommunications channels, token ring, Ethernet or modems. Alternatively,the base computer system 101 may communicate using a wireless interface,such as a cellular digital packet data (CDPD) card. The base computersystem 101 may be associated with such other computers in a local areanetwork (LAN) or a wide area network (WAN), or the base computer system101 may be a client in a client/server arrangement with anothercomputer, etc.

FIG. 2 illustrates a data processing network 200 in which the presentinvention may be practiced. The data processing network 200 may includea plurality of individual networks, such as a wireless network and awired network, each of which may include a plurality of individualworkstations 201, 202, 203, 204 and or the base computer system 101 ofFIG. 1C. Additionally, as those skilled in the art will appreciate, oneor more LANs may be included, where a LAN may comprise a plurality ofintelligent workstations coupled to a host processor.

Programming code 111 may be embodied in the memory 105, and accessed bythe processor 106 using the processor bus. Such programming codeincludes an operating system which controls the function and interactionof the various computer components and one or more application programs112. Program code is normally paged from long-term storage 107 tohigh-speed memory 105 where it is available for processing by theprocessor 106. The techniques and methods for embodying softwareprogramming code in memory, on physical media, and/or distributingsoftware code via networks are well known and will not be furtherdiscussed herein. Program code, when created and stored on a tangiblemedium (including but not limited to electronic memory modules (RAM),flash memory, Compact Discs (CDs), DVDs, Magnetic Tape and the like isoften referred to as a “computer program product”. The computer programproduct medium is typically readable by a processing circuit preferablyin a computer system for execution by the processing circuit.

The cache that is most readily available to the processor (normallyfaster and smaller than other caches of the processor) is the lowest (L1or level one) cache and main store (main memory) is the highest levelcache (L3 if there are 3 levels). The lowest level cache is oftendivided into an instruction cache (I-Cache) holding machine instructionsto be executed and a data cache (D-Cache) holding data operands.

Still referring to FIG. 2, the networks may also include mainframecomputers or servers, such as a gateway computer (client server) 206 orapplication server (remote server) 208 which may access a datarepository and may also be accessed directly from a workstation 205. Agateway computer 206 serves as a point of entry into each network 207. Agateway is needed when connecting one networking protocol to another.The gateway computer 206 may be preferably coupled to another network(the Internet 207 for example) by means of a communications link. Thegateway computer 206 may also be directly coupled to the one or moreworkstations 101, 201, 202, 203, and 204 using a communications link.The gateway computer may be implemented utilizing an IBM eServer™zSeries® z9® Server available from International Business MachinesCorporation.

In an embodiment, software programming code which embodies the presentinvention is accessed by the processor 106 of the base computer system101 from long-term storage media, such as the long-term storage 107 ofFIG. 1C. The software programming code may be embodied on any of avariety of known media for use with a data processing system, such as adiskette, hard drive, or CD-ROM. The code may be distributed on suchmedia, or may be distributed to users 210 and 211 from the memory orstorage of one computer system over a network to other computer systemsfor use by users of such other systems.

Referring to FIG. 3, an exemplary processor embodiment is depicted forprocessor 106. One or more levels of cache 303 are employed to buffermemory blocks in order to improve the performance of the processor 106.The cache 303 is a high speed buffer holding cache lines of memory datathat are likely to be used. Typical cache lines are 64, 128 or 256 bytesof memory data. In an embodiment, separate caches are employed forcaching instructions than for caching data. Cache coherence(synchronization of copies of lines in memory and the caches) is oftenprovided by various “snoop” algorithms well known in the art. Mainstorage, such as memory 105 of a processor system is often referred toas a cache. In a processor system having 4 levels of cache 303 memory105 is sometimes referred to as the level 5 (L5) cache since it istypically faster and only holds a portion of the non-volatile storage(DASD, Tape etc) that is available to a computer system. Memory 105“caches” pages of data paged in and out of the memory 105 by theoperating system.

A program counter (instruction counter) 311 keeps track of the addressof the current instruction to be executed. A program counter in az/Architecture processor is 64 bits and may be truncated to 31 or 24bits to support prior addressing limits. A program counter is typicallyembodied in a program status word (PSW) of a computer such that itpersists during context switching. Thus, a program in progress, having aprogram counter value, may be interrupted by, for example, the operatingsystem (i.e., the current context switches from the program environmentto the operating system environment). The PSW of the program maintainsthe program counter value while the program is not active, and theprogram counter (in the PSW) of the operating system is used while theoperating system is executing. In an embodiment, the program counter isincremented by an amount equal to the number of bytes of the currentinstruction. Reduced Instruction Set Computing (RISC) instructions aretypically fixed length while Complex Instruction Set Computing (CISC)instructions are typically variable length. Instructions of the IBMz/Architecture are CISC instructions having a length of 2, 4 or 6 bytes.The program counter 311 is modified by either a context switch operationor a branch taken operation of a branch instruction for example. In acontext switch operation, the current program counter value is saved inthe PSW along with other state information about the program beingexecuted (such as condition codes), and a new program counter value isloaded pointing to an instruction of a new program module to beexecuted. A branch taken operation is performed in order to permit theprogram to make decisions or loop within the program by loading theresult of the branch instruction into the program counter 311.

In an embodiment, an instruction fetch unit 305 is employed to fetchinstructions on behalf of the processor 106. The instruction fetch unit305 either fetches the “next sequential instructions,” the targetinstructions of branch taken instructions, or the first instructions ofa program following a context switch. In an embodiment, the instructionfetch unit 305 employs prefetch techniques to speculatively prefetchinstructions based on the likelihood that the prefetched instructionsmight be used. For example, the instruction fetch unit 305 may fetch 16bytes of instructions that include the next sequential instruction andadditional bytes of further sequential instructions.

The fetched instructions are then executed by the processor 106. In anembodiment, the fetched instruction(s) are passed to a decode/dispatchunit 306 of the instruction fetch unit 305. The decode/dispatch unit 306decodes the instruction(s) and forwards information about the decodedinstruction(s) to appropriate execution units 307, 308, and/or 310. Anexecution unit 307 receives information about decoded arithmeticinstructions from the instruction fetch unit 305 and will performarithmetic operations on operands according to the operation code(opcode) of the instruction. Operands are provided to the execution unit307 either from the memory 105, architected registers 309, or from animmediate field of the instruction being executed. Results of theexecution, when stored, are stored either in memory 105, architectedregisters 309 or in other machine hardware (such as control registers,PSW registers and the like).

A processor 106 typically has one or more execution units 307, 308, and310 for executing the function of the instruction. Referring to FIG. 4A,an execution unit 307 may communicate with the architected registers309, the decode/dispatch unit 306, the load/store unit 310 and otherprocessor units 401 by way of interfacing logic 407. The execution unit307 may employ several register circuits 403, 404, and 405 to holdinformation that the arithmetic logic unit (ALU) 402 will operate on.The ALU 402 performs arithmetic operations such as add, subtract,multiply and divide as well as logical function such as and, or andexclusive-or (xor), rotate and shift. In an embodiment, the ALU 402supports specialized operations that are design dependent. Othercircuits may provide other architected facilities 408 includingcondition codes and recovery support logic for example. Typically theresult of an ALU operation is held in an output register circuit 406which can forward the result to a variety of other processing functions.In other embodiments, there are many arrangements of processor units,the present description is only intended to provide a representativeunderstanding of one embodiment.

An ADD instruction for example would be executed in an execution unit307 having arithmetic and logical functionality while a floating pointinstruction for example would be executed in a floating point executionunit (not shown) having specialized floating point capability.Preferably, an execution unit operates on operands identified by aninstruction by performing an opcode defined function on the operands.For example, an ADD instruction may be executed by an execution unit 307on operands found in two architected registers 309 identified byregister fields of the instruction.

The execution unit 307 performs the arithmetic addition on two operandsand stores the result in a third operand where the third operand may bea third register or one of the two source registers. The execution unit307 preferably utilizes an arithmetic logic unit (ALU) 402 that iscapable of performing a variety of logical functions such as shift,rotate, and, or and XOR as well as a variety of algebraic functionsincluding any of add, subtract, multiply, divide. Some ALUs 402 aredesigned for scalar operations and some for floating point. Inembodiments, data may be big endian (where the least significant byte isat the highest byte address) or little endian (where the leastsignificant byte is at the lowest byte address) depending onarchitecture. The IBM z/Architecture is big endian. Signed fields may besign and magnitude, 1's complement or 2's complement depending onarchitecture. A 2's complement number is advantageous in that the ALU402 does not need to design a subtract capability since either anegative value or a positive value in 2's complement requires only andaddition within the ALU. Numbers are commonly described in shorthand,where a 12 bit field defines an address of a 4,096 byte block and iscommonly described as a 4 Kbyte (Kilo-byte) block for example.

Referring to FIG. 4B, Branch instruction information for executing abranch instruction is typically sent to a branch unit 308 which employsa branch prediction algorithm such as a branch history table 432 topredict the outcome of the branch before other conditional operationsare complete. The target of the current branch instruction will befetched and speculatively executed before the conditional operations arecomplete. When the conditional operations are completed thespeculatively executed branch instructions are either completed ordiscarded based on the conditions of the conditional operation and thespeculated outcome. A typical branch instruction may test conditioncodes and branch to a target address if the condition codes meet thebranch requirement of the branch instruction, a target address may becalculated based on several numbers including ones found in registerfields or an immediate field of the instruction for example. In anembodiment, the branch unit 308 may employ an ALU 426 having a pluralityof input register circuits 427, 428, and 429 and an output registercircuit 430. The branch unit 308 may communicate with general registers,decode/dispatch unit 306 or other circuits 425 for example.

The execution of a group of instructions may be interrupted for avariety of reasons including a context switch initiated by an operatingsystem, a program exception or error causing a context switch, an I/Ointerruption signal causing a context switch or multi-threading activityof a plurality of programs (in a multi-threaded environment) forexample. In an embodiment, a context switch action saves stateinformation about a currently executing program and then loads stateinformation about another program being invoked. State information maybe saved in hardware registers or in memory for example. Stateinformation includes a program counter value pointing to a nextinstruction to be executed, condition codes, memory translationinformation and architected register content. A context switch activitymay be exercised by hardware circuits, application programs, operatingsystem programs or firmware code (microcode, pico-code or licensedinternal code (LIC) alone or in combination.

A processor accesses operands according to instruction defined methods.The instruction may provide an immediate operand using the value of aportion of the instruction, may provide one or more register fieldsexplicitly pointing to either general purpose registers or specialpurpose registers (floating point registers for example). Theinstruction may utilize implied registers identified by an opcode fieldas operands. The instruction may utilize memory locations for operands.A memory location of an operand may be provided by a register, animmediate field, or a combination of registers and immediate field asexemplified by the z/Architecture long displacement facility wherein theinstruction defines a base register, an index register and an immediatefield (displacement field) that are added together to provide theaddress of the operand in memory. Location herein implies a location inmain memory (main storage) unless otherwise indicated.

Referring to FIG. 4C, a processor accesses storage using a load/storeunit 310. The load/store unit 310 may perform a load operation byobtaining the address of the target operand in memory through thecache/memory interface and loading the operand in an architectedregister 309 or another memory location, or may perform a storeoperation by obtaining the address of the target operand in memory andstoring data obtained from an architected register 309 or another memorylocation in the target operand location in memory. The load/store unit310 may be speculative and may access memory in a sequence that isout-of-order relative to the instruction sequence; however theload/store unit 310 maintains the appearance to programs thatinstructions were executed in order. A load/store unit 310 maycommunicate with architected registers 309, decode/dispatch unit 306,cache/memory interface or other elements 455 and comprises variousregister circuits, ALUs 458 and control logic 463 to calculate storageaddresses and to provide pipeline sequencing to keep operationsin-order. Some operations may be out of order but the load/store unitprovides functionality to make the out of order operations appear to theprogram as having been performed in order as is well known in the art.

Preferably addresses that an application program “sees” are oftenreferred to as virtual addresses. Virtual addresses are sometimesreferred to as “logical addresses” and “effective addresses.” Thesevirtual addresses are virtual in that they are redirected to physicalmemory location by one of a variety of DAT technologies such as the DAT312 of FIG. 3, including, but not limited to prefixing a virtual addresswith an offset value, translating the virtual address via one or moretranslation tables, the translation tables including at least a segmenttable and a page table alone or in combination, preferably, the segmenttable having an entry pointing to the page table. In z/Architecture, ahierarchy of translations is provided including a region first table, aregion second table, a region third table, a segment table and anoptional page table. The performance of the address translation is oftenimproved by utilizing a translation look-aside buffer (TLB) whichcomprises entries mapping a virtual address to an associated physicalmemory location. The entries are created when DAT 312 translates avirtual address using the translation tables. Subsequent use of thevirtual address can then utilize the entry of the fast TLB rather thanthe slow sequential translation table accesses. The TLB content may bemanaged by a variety of replacement algorithms including least recentlyused (LRU).

In the case where the processor 106 is a processor of a multi-processorsystem, each processor has responsibility to keep shared resources suchas I/O, caches, TLBs and Memory interlocked for coherency. In anembodiment, “snoop” technologies will be utilized in maintaining cachecoherency. In a snoop environment, each cache line may be marked asbeing in any one of a shared state, an exclusive state, a changed state,an invalid state and the like in order to facilitate sharing.

The I/O units 304 of FIG. 3 provide the processor 106 with means forattaching to peripheral devices including tape, disc, printers,displays, and networks for example. The I/O units 304 are oftenpresented to the computer program by software drivers. In mainframessuch as the z/Series from IBM, channel adapters and open system adaptersare I/O units of the mainframe that provide the communications betweenthe operating system and peripheral devices.

Instrumentation data is data related to the operations of the processor106. In an embodiment, access to instrumentation data and other systemlevel metrics may be restricted, or unavailable. A computer processoroperates under a privileged state (or supervisor state), and alesser-privileged state (or problem state). In the privileged state, aprogram may have access to all system resources via privilegedoperations (e.g., access to all control registers and the supervisormemory space). The privileged state is also referred to as privilegedmode or supervisor mode. An operating system executing on the computerprocessor may be operating in the privileged state. Thelesser-privileged state is a non-privileged state where access to systemresources is limited. For example, application programs running inlesser-privileged state may have limited or no access to controlregisters and may access only user memory space assigned to theapplication program by the operating system. The lesser-privileged stateis typically assigned to application programs executed under control ofan operating system, and no privileged operations can be performed inthe lesser-privileged state. The lesser-privileged state is also knownas a problem state, problem mode or user mode.

One such restricted resource that is not write-accessible to a programexecuting in the lesser-privileged state is the program status word(PSW). The PSW may comprise a program counter of the next instruction tobe executed, a condition code field usable by branch instructions, aninstrumentation control field for indicating whether instrumentation isenabled or disabled, and other information used to control instructionsequencing and to determine the state of the computer processorincluding the privilege state assigned to the program. In amultithreaded processing environment, multiple programs share, or timeslice, the available computer processor capacity. Each of the programshas context information including an associated PSW, an origin addressof an address translation table for accessing main storage assigned tothe program, a set of general purpose register current values, controlregisters, floating point registers, etc. The currently active, orcontrolling PSW, is called the current PSW. It governs the programcurrently being executed. The computer processor has an interruptioncapability, which permits the computer processor to context switchrapidly to another program in response to exception conditions andexternal stimuli. When an interruption occurs, the computer processorplaces the current PSW in an assigned storage location, called theold-PSW location, for the particular class of interruption. The computerprocessor fetches a new PSW from a second assigned storage location.This new context determines the next program to be executed. In anembodiment, these storage locations are located in a memory locationaccessible to the computer processor. When the computer processor hasfinished processing the interruption, the program handling theinterruption may reload the old context including the old PSW, making itagain the current PSW, so that the interrupted program can continue.

The fields of the PSW may be referenced either explicitly (e.g., wheninstruction execution reads part of the PSW bits), or implicitly (e.g.,in instructions fetching, operand fetching, address generationcalculations, address generation sources, etc.). The explicit referenceis generally performed at execution time, whereas the implicit referenceis generally performed at different stages of the pipeline duringinstruction execution (i.e., instruction fetch, instruction decode,execution time and completion time). Individual fields in the PSW may bereferenced or updated independently of each other.

In an embodiment, by manipulating the context, an operating systemcontrols computer processing resources, including enablingrun-time-instrumentation by the computer processor. Therun-time-instrumentation may be enabled or disabled during the executionof the operating system, as well as by any software applicationsexecuted by the operating system. The enabled/disabled state ofrun-time-instrumentation is saved as context information in the PSWassociated with a program.

A run-time-instrumentation (RI) facility may be incorporated on modelsimplementing z/Architecture. When the RI facility is installed andenabled, data is collected during program execution into one or morecollection buffers within the CPU and then reported to a program buffer.Each unit of information stored is called a reporting group. Thecontents of a reporting group consist of multiple records whose contentsrepresent events recognized by the CPU during program execution.

When the run-time-instrumentation facility is installed in aconfiguration, a PSW field (RI bit) enables run-time-instrumentation.Validity of the run-time-instrumentation controls determines thecapability of turning on the RI bit, but when RI is one, the CPUcontrols are valid and run-time-instrumentation is enabled. Therun-time-instrumentation facility may include the followinginstructions: load run-time-instrumentation controls, modifyrun-time-instrumentation controls, run-time-instrumentation emit,run-time-instrumentation next, run-time-instrumentation off,run-time-instrumentation on, store run-time-instrumentation controls,and test run-time-instrumentation controls.

The load run-time-instrumentation controls (LRIC) instructioninitializes the run-time-instrumentation controls that governrun-time-instrumentation. The modify run-time-instrumentation controls(MRIC) instruction modifies all or a subset of therun-time-instrumentation controls originally established by LRIC. Therun-time-instrumentation emit (RIEMIT) instruction collects the value ofa general register by storing it into a collection buffer. Therun-time-instrumentation next (RINEXT) instruction performs directedsampling of the next, sequential instruction (NSI) after RINEXT. Therun-time-instrumentation off (RIOFF) instruction disablesrun-time-instrumentation. The run-time-instrumentation on (RION)instruction enables run-time-instrumentation. The storerun-time-instrumentation controls (STRIC) instruction places the currentvalues of the run-time-instrumentation controls into a specified storagelocation. The test run-time-instrumentation controls (TRIC) instructionexamines the run-time-instrumentation controls. If valid, the state of acontrols-altered indicator is set.

The run-time-instrumentation facility includes the ability for making ameasurement-alert external interruption pending. Some of the informationcollected by run-time-instrumentation and reported to a program bufferis model-dependent and thus not defined. Samples and data provided bythe run-time-instrumentation facility are intended for statisticalestimation of performance characteristics, are substantially accurate,and may not be repeatable. For example, regardless of sampling mode, itis unpredictable if a sample instruction that caused an exception or isassociated with certain system internal activities would result in thestore of a reporting group and, if stored, whether the model-dependentdata included in run-time-instrumentation data is affected.

A collection buffer is used to capture a set of records whose contentsreport on events recognized by the processor during program execution.Examples are: execution of one or more taken branches,transactional-execution abort events, and an operand of the RIEMITinstruction. Execution of the RIEMIT instruction collects the value of ageneral register by storing it into the collection buffer. Additionaldata can be collected and/or stored in other buffers, such as aninstruction-data buffer.

Reporting is subject to reporting controls. When a sample instruction isidentified, each reporting control enables the checking of acorresponding condition. If a corresponding condition exists, areporting group is formed and stored. A reporting group is not storedwhen no reporting control is enabled or the corresponding condition doesnot exist for an enabled reporting control. Data reported about a sampleinstruction is acquired from the instruction-data buffer and othermodel-dependent sources, and then used to create the contents of one ormore records of the reporting group, one such record being aninstruction record.

Record types that may be captured in the reporting group store include:filler, extra, begin, timestamp, instruction, emit, TX abort, call,return, and transfer. A filler record is used in a reporting group whenthe number of valid records in the collection buffer is not sufficientto fill a reporting group of the current reporting-group size. An extrarecord may be used in the extra section of a reporting group. A beginrecord is the first record of the first reporting group. A timestamprecord is stored as record 0 of every reporting group other than thefirst reporting group. An instruction record is created when a reportinggroup is stored for a sample instruction as the last record of thereporting group. An emit record is created by successful execution ofRIEMIT. A transaction-execution (TX) mode abort record is created byeither an implicit abort or by execution of a transaction abortinstruction. A call record is created by execution of a branchinstruction which is categorized as a call-type branch instruction. Areturn record is created by execution of a return-type branchinstruction which is categorized as a return instruction. A transferrecord is created by execution of a branch instruction which meetscertain condition code criteria.

FIG. 5 depicts a schematic diagram of a system forrun-time-instrumentation of a processor that may be implemented in anembodiment. In an embodiment, the system 500 includes a centralprocessing unit (CPU) such as the processor 106 of FIG. 1. In anembodiment, the processor 106 is a single processor. In an alternateembodiment, the processor 106 is a single processing core of amulti-core processor. In an embodiment, the processor 106 is capable ofoperating at varying speeds.

In an embodiment, the processor 106 further includes a register 510. Theregister 510 is a hardware register capable of storing words of data foruse by the processor 106. The register 510 includes one or more latchesfor storing bits of data that are accessible by the processor 106. Theregister 510, may include general purpose registers and controlregisters for example. The processor 106 additionally includes aninstrumentation module 506 that is in communication with the register510. The instrumentation module 506 controls the instrumentation of theprocessor 106. The instrumentation module 506 is configured to collectinstrumentation data, such as the execution path of one or more takenbranches, transactional execution abort events, various runtimeoperands, timestamp information, etc. directly from the processor 106.The instrumentation module 506 collects the instrumentation data fromthe processor 106, and stores the instrumentation data in a collectionbuffer 508. In an embodiment, the collection buffer 508 is a circularbuffer that collects data received from the instrumentation module 506,and when the circular buffer is filled it overwrites the oldest datawith new data.

The processor 106 executes one or more operating systems 516 and one ormore applications 518. The one or more operating systems 516 and one ormore applications 518 are stored in a storage 520, such as a hard drive,CD/ROM, flash memory, etc. and are loaded into a main memory 514 in aruntime memory 504 area reserved for storing one or more active piecesof the currently executing operating system and/or application, calledpages, which are loaded from the storage 520 into runtime memory 504 asneeded. In an embodiment, each of the operating systems execute as avirtual machine managed by a hypervisor (not shown) and executed by theprocessor 106.

In an embodiment the processor 106 loads a PSW in the register 510 fromPSW data 512 in main memory 514 for the currently executing operatingsystem or application from the main memory 514 and sets one or moreprocessor settings in, for example, the register 510. In an embodiment,the PSW in the register 510 includes one or more bits for enabling andcontrolling the instrumentation module 506.

The one or more applications 518 include software applications compiledto execute on a specific operating system, interpreted code executing onan interpreter (e.g., Java™), or operating system support threads (e.g.,process management, daemons, etc.). Each of the one or more operatingsystems 516 and or the one or more applications 518 may execute aninstruction to trigger the instrumentation module 506 to start, or tostop, the collecting instrumentation data.

In an embodiment, one of the one or more applications 518 executes aninstruction that has been determined to be a sample instruction, therebycreating a sample point at the completion of execution of the sampleinstruction and that then causes the instrumentation module 506 to movethe application's collected data from the collection buffer 508, to aprogram buffer 522 in main memory 514 that is accessible to theapplication. The main memory 514 may be any addressable memory known inthe art. In an embodiment, the main memory 514 may include a fast-accessbuffer storage, sometimes called a cache. Each CPU may have anassociated cache. In an additional embodiment, the main memory 514 isdynamic random access memory (DRAM). In a yet another embodiment, themain memory is a storage device, such as a computer hard drive, or flashmemory accessible by an application.

A run-time-instrumentation function is a new facility that may be usedin not only in a laboratory environment, or for off-line analysis, butalso in live software environments within programs at runtime, and underprogram control. A privileged state may set controls of a processor 106to manage run-time-instrumentation. The flexibility of therun-time-instrumentation facility is enhanced by providing the abilityto change most of the controls from a lesser-privileged state. Thelesser-privileged state is most likely to receive a benefit fromrun-time-instrumentation. A lesser-privileged state is prohibited fromchanging certain settings in order to ensure that (1) the privilegedstate maintains integrity and control over all the lesser-privilegedstate programs that it runs, and (2) a lesser-privileged state may ormay not perform run-time-instrumentation when the operating systemitself is performing run-time-instrumentation. Both may performrun-time-instrumentation if the supervisor momentarily disablesrun-time-instrumentation, saves its run-time-instrumentation context,restores the less-privileged state program's run-time-instrumentationcontext, and then starts the less-privileged state program withrun-time-instrumentation re-enabled. If the context change does notinclude the appropriate saving/restoring of the run-time-instrumentationcontrols, a collision of data collected in both the privileged andlesser-privileged states would likely be an unusable collection ofrun-time-instrumentation data.

In an embodiment, in order to better support the lesser-privileged stateprogram, a modify run-time-instruction (MRIC) instruction is defined.The MRIC instruction is a semi-privileged instruction that is used tomodify certain processor 106 controls related torun-time-instrumentation, those controls which are currently active inthe register 510. The controls are originally loaded by successfulexecution of the load run-time-instruction control (LRIC) instruction bythe privileged state.

The MRIC instruction's ability to interact with therun-time-instrumentation controls is described in the details below. Ifthe execution of the MRIC instruction is successful, then all controlsthat are specified by the MRIC instruction are set when execution ofMRIC successfully completes, otherwise, if the execution of the MRICinstruction is unsuccessful, then no controls are affected.

FIG. 6 depicts an MRIC instruction in an embodiment. In an embodiment,the MRIC instruction 600 includes an operation code 602 and 604 (alsoreferred to as “opcode” or “split opcode” in this particular case). Theopcode 602 and 604 identifies the MRIC instruction 600 to the processor,such as the processor 106 of FIG. 5. The MRIC instruction 600 alsoincludes an operand address which is determined from a base registerfield 606 (B₂), and a set of displacement fields 608 and 610, takentogether. The sum of the contents of the base register plus thedisplacement indicates the location of a run-time-instrumentationcontrols control block (RICCB) that includes therun-time-instrumentation control settings that will be updated by theMRIC instruction. The displacement fields 608 and 610 indicate adisplacement from the address contained in the base register indicatedby the base register field 606 whose summation lines up with the RICCB.FIG. 6 depicts an embodiment of the MRIC instruction for purposes ofclarity. It will be understood by those of ordinary skill in the artthat the MRIC instruction may be formatted differently and/or containdifferent operands and opcodes in other embodiments.

The MRIC instruction 600 is used to update only a subset of controlsthat are updateable by an LRIC instruction. The controls set by an MRICinstruction 600 are limited to a subset of controls that have beensuccessfully set by an LRIC instruction. The run-time-instrumentationcontrols include a number of bits that control the operation of the MRICinstruction, including the ability to update variousrun-time-instrumentation controls. In an embodiment, these bits arelocated in the subset of all run-time-instrumentation controls that mayonly be set by an LRIC instruction.

FIG. 7 depicts a process flow for initiating an MRIC instruction from alesser-privileged state program in an embodiment. At block 702, an MRICinstruction is fetched by the processor. At block 704, the MRICinstruction is executed by the processor. At block 706, therun-time-instrumentation control values in the RICCB are loaded in therun-time-instrumentation controls. At block 708, therun-time-instrumentation controls provide information to the programbuffer 522 of FIG. 5 based on the loaded settings.

FIG. 8 depicts a process flow for initiating an MRIC instruction from alesser-privileged state program in an additional embodiment. In anembodiment, the process flow of FIG. 8 is executed by theinstrumentation module 506 of FIG. 5. At block 802, an MRIC instructionissued by a lesser-privileged state program is fetched. The MRICinstruction includes an opcode and an operand. The operand of the MRICinstruction is the RICCB that includes run-time-instrumentation controlvalues that will be used to update the run-time-instrumentationcontrols. These values include, for example, a control value to managedetails of run-time-instrumentation data sampling; a control value tomanage details of run-time-instrumentation data collection; a controlvalue to manage details of run-time-instrumentation data reporting intothe program buffer; a current address within a location of a programbuffer, etc.

At block 804 it is determined if execution of MRIC is permitted. Therun-time-instrumentation S bit (controlled only by LRIC) determines ifthe lesser-privileged state program is allowed to execute the MRICinstruction. If the run-time-instrumentation S bit is set to 1, thenprocessing continues at block 806.

At block 806, it is determined if the validity bit (also referred to asthe V bit) of the current run-time-instrumentation controls is set to 1.The validity bit indicates the validity of the set ofrun-time-instrumentation controls in the processor, as they werepreviously set by an LRIC instruction. If the currentrun-time-instrumentation controls are not valid, (i.e. the previous LRICinstruction was invalid), then at block 818 successful execution of MRICinstruction cannot occur. In an embodiment, unsuccessful execution ofMRIC instruction does not change the prior settings and the runtimecontrols remain at their prior values. The validity bit cannot beupdated by the MRIC instruction. At block 808, the RICCB that the MRICinstruction points to is fetched.

If the validity bit is set to 1 (i.e. the run-time-instrumentationcontrols are valid), then processing continues at block 810. At block810, if the K bit is zero (i.e., the lesser-privileged state program isnot executing in a semi-privileged state with regard to therun-time-instrumentation controls), then, at block 814, neither theorigin address nor the limit address is updated, but all other controlspermitted to be updated by MRIC are updated. If the K bit is one (i.e.,the lesser-privileged state program is executing in a semi-privilegedstate with regard to the run-time-instrumentation controls), then, atblock 812, all controls permitted to be updated by MRIC are updated,including the origin address and limit address.

FIG. 9 depicts a portion of a run-time-instrumentation controls controlblock (RICCB) including controls that are settable by a privileged statein an embodiment. The control block portion 900 may include additionalvalues other than those described in reference to FIG. 9. Modificationto the control block portion 900 may be performed by an LRICinstruction.

The control block portion includes a validity bit 902 (V bit). Thevalidity bit 902 indicates the validity of the set ofrun-time-instrumentation controls in the processor, as they werepreviously set by an LRIC instruction.

The control block also includes an S bit 904, which is used to determineif the lesser-privileged state program is allowed to execute the MRICinstruction. The K bit 906 indicates if the lesser-privileged stateprogram is permitted to execute in a semi-privileged state with regardto the run-time-instrumentation controls, such as the origin address,and the limit address of the run-time-instrumentation controls. The Hbit 908 determines whether the address controls (i.e., the originaddress, limit address, and current address) refer to a primary virtualaddress space or a home virtual address space. The 0 bit 910 is ignoredand treated as a 0.

A lesser-privileged state sample reporting control bit 912 (Ps bit) isused in conjunction with lesser-privileged state programs. When in thelesser-privileged state and the Ps bit 912 in therun-time-instrumentation controls is zero, the reporting controls of therun-time-instrumentation controls are ignored whenrun-time-instrumentation is enabled, and thus do not cause a reportinggroup to be stored. When in the lesser-privileged state and the Ps bit912 in the run-time-instrumentation controls is one, the reportingcontrols are checked and used according to their defined function.

A supervisor-state sample reporting control bit 914 (Qs bit) is used inconjunction with supervisor-state programs. When in the supervisor stateand the Qs bit 914 in the run-time-instrumentation controls is zero, thereporting controls of the run-time-instrumentation controls are ignoredwhen run-time-instrumentation is enabled, and thus do not cause areporting group to be stored. When in the supervisor state and the Qsbit 914 in the run-time-instrumentation controls is one, the reportingcontrols are checked and used according to their defined function.

The lesser-privileged state collection buffer control bit 916 (Pc bit)controls updates to the collection buffer 508 of FIG. 5. When inlesser-privileged state and the Pc bit 916 in therun-time-instrumentation controls is zero, collection buffer controls ofthe run-time-instrumentation controls are ignored whenrun-time-instrumentation is enabled and updates of the collection buffer508 are prevented. When in the lesser-privileged state and the Pc bit916 in the run-time-instrumentation controls is one, the collectionbuffer controls are checked and used according to their definedfunction.

The supervisor-state collection buffer control bit 918 (Qc bit) controlsupdates to the collection buffer 508. When in supervisor state and theQc bit 918 in the run-time-instrumentation controls is zero, collectionbuffer controls of the run-time-instrumentation controls are ignoredwhen run-time-instrumentation is enabled and the updates to thecollection buffer 508 are prevented. When in supervisor state and the Qcbit 918 in the run-time-instrumentation controls is one, the indicatedcollection-buffer controls are checked and used according to theirdefined function.

The G bit 920 is the pending control of arun-time-instrumentation-halted interruption, also called a haltedinterruption. When the G bit 920 is zero, a halted interruption is notpending. When the G bit 902 is one, a halted interruption is pending.When the first reporting group in a program buffer 522 is written, the Gbit 920 is set to zero. That is, when an origin address of the programbuffer equals a limit address of the program buffer the G bit 920 is setto zero. When an attempt to store other than the first reporting groupin program buffer 522 is made, the G bit 920 is set to zero if therun-time-instrumentation-halted condition does not exist, and thereporting group is stored. When an attempt to store other than the firstreporting group in program buffer 522 is made, the G bit 920 is set toone if the run-time-instrumentation-halted condition does exist, and thereporting group is not stored.

The U bit 922 is the enablement control for a buffer-full interruptionand a halted interruption. When U bit 922 is zero, generation of aninterruption request is disabled and, if pending, remains pending.

The L bit 924 is the pending control of a buffer-full interruption. WhenL bit 924 is zero, a buffer-full interruption is not pending. When L bit924 is one, a buffer-full interruption is pending.

The key field 926 is a 4-bit unsigned integer whose value is used as astorage-protect key for the store of a reporting group. A store of areporting group is permitted only when the storage key matches theaccess key associated with the request for storage access, and a fetchis permitted when the storage key matches the access key or when afetch-protection bit of the storage key is zero. The keys match when thefour access control bits of the storage key are equal to the access key,or when the access key is zero.

FIG. 10 depicts a portion of an RICCB control block when MRIC ispermitted to execute in semi-privileged mode (i.e., K bit is one). Thecontrol block 1000 may include additional values other than thosedescribed in reference to FIG. 10. In an embodiment, any grayed outsections of the MRIC instruction operand are not accessible by alesser-privileged state program. When the semi-privileged mode ispermitted, the origin address (ROA) 1002 and the limit address 1004 areset with the MRIC instruction by the lesser-privileged state program.

In an embodiment, a current address field (RCA) 1006 may be updated bythe MRIC instruction. The current address field 1006 examines thereporting group size field 1044 (RGS field) and affects the number ofsignificant bit positions used to form the address of the programbuffer. The 64-bit run-time-instrumentation program buffer currentaddress is word 0, bit positions 0 through 26-RGS of word 1, and RGS+5binary zeros appended on the right. This is the starting location in theprogram buffer 522 of FIG. 5 of a subsequent reporting group that willbe stored in the program buffer 522. The reporting group is a unit ofinformation that is created by the instrumentation module 506, andsubsequently stored in the program buffer 522. In an embodiment, whenthe RGS field 1044 specified by the current address field 1006 is notequal to the run-time-instrumentation control's current reporting groupsize (i.e. the current address field 1006 would change the RGS field1044) then the current address field 1006 is set to the origin address1002.

A remaining sample interval count field 1042 (RSIC field) may be updatedby the lesser-privileged program using the MRIC instruction. The RSICfield 1042 includes a 64-bit unsigned integer that indicates a remainingsample interval count. When the value of the RSIC field 1042 in therun-time-instrumentation controls is zero or equal to the value in ascaling factor field 1040 (SF field), and run-time-instrumentation isenabled, then the next sample interval is a full interval based on thesampling mode field 1008 (M field) and SF field 1040 values. When RSICfield 1042 is nonzero and less than the SF field 1040 andrun-time-instrumentation is enabled, the next sample interval is apartial interval. When the RSIC field 1042 is nonzero and greater thanthe SF field 1040 value and run-time-instrumentation is enabled, thenext sample interval is an extended interval. When an extended intervalexpires, the next interval is based on the SF field 1040 value. When theRSIC field 1042 is set to a nonzero value, it is subject to the samemodel-dependent maximum limit to which the SF field 1040 is alsosubject. When the original value of the RSIC field 1042 is zero, thesampling mode will dictate whether the RSIC field 1042 is set to thevalue in the SF field 1040 during execution of LRIC and MRICinstructions, or whether it continues to show as zero untilrun-time-instrumentation is enabled.

The SF field 1040 contains a 64-bit unsigned integer whose value is ascaling factor count of units. The dimension of the units is determinedfrom the sampling mode field 1008 (M field). When the value in the RSICfield 1042 is zero, the SF field 1040 provides an initial value of theRSIC field 1042 that is decremented to zero at which point the currentinstruction is recognized as a sample instruction, and the intervalcount is refreshed from the SF field 1040 value. A valid value of the SFfield 1040 is in the range one to 2⁶⁴-1. If zero is specified, a valueof one is assumed. However, each model may have both a minimum and amaximum value of the SF field 1040. The minimum and maximum values mayalso be different based on the sampling mode field 1008. If a value lessthan the minimum is specified, the model-dependent minimum value isloaded. If a value greater than the maximum value is specified, themodel-dependent maximum value is loaded.

The DC control field 1036 is a 4-bit unsigned integer whose valuedesignates a cache-latency level associated with a data fetch or storecache miss. That is, the sample instruction encountered a data accesscache miss. Unless prohibited by another run-time-instrumentationcontrol, an attempt is made to store a reporting group representing thesample instruction whose data access recognized a miss at acache-latency level numerically greater than or equal to the leveldesignated by the value of the DC control field 1036. The cachestructure and cache-latency level for data access is model dependent.For an instruction with multiple or long operands, it is model dependentwhich, if any, operand access is used for reporting control.Model-dependent behavior may ignore the value of the DC control field1036 and thus not use it as a reason to store a reporting group.

The IC field 1034 is a 4-bit unsigned integer whose value designates acache-latency level associated with an instruction-fetch cache miss.That is, the fetch of the sample instruction encountered aninstruction-fetch cache miss. For both the IC field 1034 and DC controlfield 1036, a cache-latency level is an abstraction of how far a certaincache level access is from the observing processor. The latency leveldepends on the combination of the amount of nested cache levels betweenthe processor and main storage, and how such cache levels are sharedamong multiple processors. A larger latency level generally correspondsto a more time-consuming access. Values in the IC field 1034 and DCcontrol field 1036 may be thought of as zero-origin identification of acache-latency level. For example, a value of zero corresponds to an L1cache (i.e., the cache that is closest to the processor). A value of oneis therefore the next layer of cache which may be known as an L2 cache,or even an L1.5 cache in some machines. Values of 2-15 designate thelogical progression of additional cache-latency layers until main memoryis reached, but not including main memory itself. Generally, cachestructures do not go as deep as fifteen layers. Therefore, a value of 15in the IC field 1034 and DC control field 1036 is interpreted as aspecial case, meaning that a cache miss on instruction fetch or dataaccess, respectively and regardless of cache-latency level, is notrecognized for the purpose of generating the store of a reporting group.Unless prohibited by another run-time-instrumentation control, anattempt is made to store a reporting group representing the sampleinstruction whose fetch recognized a miss at a cache-latency levelnumerically greater than or equal to the level designated by the valueof the IC field 1034. The cache structure and cache-latency level forinstruction fetching is model dependent. Model-dependent behavior mayignore the value of the IC field 1034 and thus not use it as a reason tostore a reporting group.

The cache-latency-level-override reporting control bit 1032 (F bit) isfor non-branch instructions and for branch-prediction controls. When theF bit 1032 in the run-time-instrumentation controls is zero, thecache-reporting controls (IC field 1034 and DC control field 1036) ofthe run-time-instrumentation controls are checked and used according totheir defined function. The branch-prediction controls (BPxn 1022, BPxt1024, BPti 1026, and BPni 1028 bits) of the run-time-instrumentationcontrols are checked and used according to their defined function. Whenthe F bit 1032 is one, these same controls are ignored and a reportinggroup is stored unless prohibited by another control.

The data-cache-miss control bit 1030 (D bit) indicates if a reportinggroup is to be stored. If the D bit 1030 is one, an extra type recordmay or may not be placed in the extra section of the reporting groupwhich contains model dependent data about the sample instruction.

The MRIC instruction includes branch-prediction (BP) reporting controls(BPxn 1022, BPxt 1024, BPti 1026, and BPni 1028). If a BP reportingcontrol bit in the run-time-instrumentation controls is zero, thecorresponding condition is not checked. If a BP reporting-control bit isone and the corresponding branch-prediction condition exists, and areporting group is stored.

The BPxn bit 1022, when one, enables checking of branch-predictioninformation. Thus, if the sample branch is incorrectly predicted to betaken but is not taken, a reporting group is stored.

The BPxt bit 1024, when one, enables checking of the branch-predictioninformation. Thus, if the sample branch is incorrectly predicted to benot taken but is taken, a reporting group is stored.

The BPti bit 1026, when one, enables checking of the branch-predictioninformation. Thus, if the sample branch is correctly predicted to betaken, and is taken, but the branch target is incorrectly predicted, areporting group is stored.

The BPni bit 1028, when one, enables checking of the branch-predictioninformation. Thus, if the sample branch is correctly predicted to not betaken, and is not taken, and the branch target is incorrectly predicted,a reporting group is stored.

The enablement control of transactional-execution-mode records bit 1020(X bit) controls the collection of transactional-execution-mode abortrecords. When the X bit 1020 in the run-time-instrumentation controls iszero, transactional-execution-mode abort records are not collected. Whenthe X bit 1020 is one, transactional-execution mode abort records arecollected and placed in the collection buffer 508 of FIG. 5. If a modeldoes not have a transactional-execution facility installed, the X bit1020 is ignored.

The RIEMIT instruction control bit 1018 (E bit) controls the executionof the RIEMIT instruction. When the E bit 1018 in therun-time-instrumentation controls is zero or ignored and treated as zerowhen run-time-instrumentation is enabled, RIEMIT executes ano-operation. When E bit 1018 is one, and not otherwise ignored, RIEMITis enabled to execute its defined function.

The J bit 1046 when zero, specifies that the branch on condition (BC)instruction is in the other-type branch category, regardless of maskvalue. If the J bit 1046 is one, the BC instruction which specifies amask of 15 is in the return-type branch category. When the BCinstruction specifies a mask of 1-14, it is not affected by the J bit1046 and is always in the other type branch category. When in thereturn-type branch category, the R bit 1016 controls inclusion into thecollection buffer 508 of FIG. 5. When in the other type branch category,the B bit 1048 controls inclusion into the collection buffer 508. Theother-type branch category may also be indicated as the transfer-typebranch category.

The instruction address code bit 1014 (C bit) controls the enablement ofcall type branches. If the C bit 1014 in the run-time-instrumentationcontrols is one and the instruction is a call-type branch, thecollection buffer is updated. If model-dependent detection of bothcall-type and return-type branches is combined, the C bit 1014 operateson both types and the R bit 1016 is not effective.

The R bit 1016 is the enablement control of return-type branches. If theR bit 1016 in the run-time-instrumentation controls is one and theinstruction is a return-type branch, then the collection buffer 508 isupdated.

The B bit 1048 is the enablement control of branches other thancall-type and return-type branches. If the B bit 1048 in therun-time-instrumentation controls is one and the instruction is another-type branch recognized by run-time-instrumentation, then thecollection buffer 508 is updated.

The maximum-address exceeded bit 1012 (MAE bit), if set to 1, indicatesthat, one or more reporting groups have been stored that have aninstruction address code (C field) set to one. Once the MAE bit 1012 isset to one, continuing execution of run-time-instrumentation does notset it back to zero. Execution of the LRIC instruction or the MRICinstruction which specifies the MAE bit as zero will set the MAE bit tozero.

The run-time-instrumentation next (RINEXT) control bit 1010 (N bit)controls the enablement of the run-time-instrumentation nextinstruction, which controls the execution of a sample instruction. Whenthe N bit 1010 in the run-time-instrumentation controls is zero orignored and treated as zero, RINEXT executes a no-operation. When the Nbit 1010 is one, and not otherwise ignored, RINEXT is enabled to executeits defined function.

The sampling mode field 1008 (M field) is a 4-bit unsigned integer whosevalue in the run-time-instrumentation controls specifies the samplingmode for the run-time-instrumentation controls.

The reporting group size field 1044 (RGS) is a 3-bit unsigned integerwhose value specifies the number of records of a reporting group (RRG).The number of records in a reporting group may vary from two records,including a begin/timestamp record and an instruction last record, up totwo hundred fifty-six records. In an embodiment, the upper limit may bemodel dependent. The number of 16-byte records placed into a reportinggroup is 2^((RGs+1)).

The primary-CPU capability suppression control bit 1038 (Y bit) and thesecondary-CPU capability suppression control bit 1039 (Z bit) arecollectively referred to as the suppression control. Suppression of thestoring of a reporting group means that an attempt to store is notperformed. The suppression control is not effective and no suppressionoccurs when the CPU capability of all CPUs in the configuration is thesame. In a configuration, if the CPU capability of a CPU differs fromthe capability of another CPU, the suppression control is in effect, andat least one CPU is said to be operating at the CPU capability orprimary-CPU capability while at least one other CPU is said to beoperating at the secondary-CPU capability. The primary and secondary CPUcapabilities are different operating speeds. When Y bit 1038 and Z bit1039 are both zero, suppression does not occur. When Y bit 1038 is zeroand Z bit 1039 is one, suppression occurs if the CPU, e.g., processor106, is operating at the secondary-CPU capability. When Y bit 1038 isone and Z bit 1039 is zero, suppression occurs if the CPU, e.g.,processor 106, is operating at the primary-CPU capability. When Y bit1038 and Z bit 1039 are both one, suppression occurs.

The above fields and bits of FIG. 10 are an example of the placement andnaming of the fields and are provided herein for purposes of clarity. Itwill be understood that in other embodiments the only a subset of thefields may be used, fields may be in any order or position, and/or maybe signified by different names.

As described previously, when run-time instrumentation is enabled duringprogram execution, run-time-instrumentation data is collected within theprocessor 106 in the collection buffer 508. In an embodiment, thecollection buffer 508 is an internal buffer of the processor 106 that isused to save the most recent records collected. When a sample triggerpoint is detected, the records are copied from the collection buffer 508into the program buffer 522 as part of a reporting group that is writtento the program buffer 522. In an embodiment, the records are copied fromthe collection buffer 508 in a non-destructive manner.

The collection buffer 508 may be referred to as a “hardware collectionbuffer” because the collection buffer 508 is located in the processorand in an embodiment implemented as an array of register pairs forstoring an instruction address and event metadata for a given event. Anexample of an event is a taken branch for which the register pair mayhold the instruction address of the branch, and the metadata may holdthe target of the branch as well as information regarding the historicbehavior of the branch. In an embodiment, the register pairs are orderedand updated sequentially as events occur in the instruction stream. Acounter is maintained to indicate the index of the most recently updatedentry in the array. In an embodiment the collection buffer 508 is acircular buffer, and when the collection buffer 508 is full, the nextevent overwrites the first entry in the array, and sequential updatingof the array's register pairs re-starts on subsequent events. As such,assuming an array CB[0] to CB[N-1] and a counter i indicating the latestupdated index, the trace of events captured would be represented by thesequence CB[i], CB[i−1] . . . CB[1], CB[0], CB[N-1], CB[N-2] . . .CB[i+1]. In another embodiment, two pointers are used: a head pointerpointing to the oldest entry in the buffer, and a tail/current pointerpointing to the newest entry in the buffer.

Events that represent a state of the processor 106 at any givenexecution point are captured sequentially in the collection buffer 508.The collection buffer 508 is used to capture a set of records whosecontents report on events recognized by the processor 106 during programexecution (e.g., execution of one or more taken branches,transactional-execution abort events, the operand of a RIEMITinstruction, etc.). In an embodiment the events recognized depend on thecontents of the RICCB shown in FIG. 10. Entries in the embodiment of thecollection buffer 508 shown include an event instruction address andother relevant event metadata. Examples of event metadata include, butare not limited to: the instruction address of a taken branch and itstarget including some information about the historic behavior of thebranch; the instruction address of a RIEMIT instruction and a respectiveregister value; and the address of a transaction abort instruction and arespective transaction recovery entry point.

An embodiment of the collection buffer 508 stores up to thirty-twoentries (i.e., information about thirty-two events), with eachinstruction address specified by sixty-four bits (e.g., bits 0:63), andevent metadata by sixty-four bits (e.g., bits 64:127). The size of thecollection buffer (RCB) is a model dependent count, representing anumber of records. In an embodiment, the byte size of the collectionbuffer 508 is a multiple of a sixteen byte record size. The size of thecollection buffer (RCB) is a number of records greater than or equal tothe difference between the count of the largest reporting group (RRG) ofthe model and the count of the records in a reporting group that are notacquired from the collection buffer (RNC). Thus, in an embodiment, thesize of the collection buffer is expressed as: RCB≦(RRG−RNC).

In an embodiment, contents of the collection buffer 508 and theinstruction data buffer (if one is used) are purged or otherwiseaffected by the following events: (1) an interruption; (2) the PSW bitthat turns on and off the run-time instrumentation facility (e.g., bit24) changes from a one to a zero; and (3) when a sample instruction isidentified when the run-time instrumentation facility is in atransactional-execution mode (in this case, further update of thecollection data buffer 508 and instruction-data buffer stops and resumeswhen the transaction ends, at which time, a store of the reporting groupis pending and the collection buffer 508 and instruction-data buffersare purged).

In an embodiment, such as the emulated host computer system shown inFIG. 1B, the collection buffer 508 is implemented using registers and/ormemory. In this embodiment, the optional instruction-data buffer, ifpresent, is also implemented using registers and/or memory.

In embodiments, additional capabilities can effect data collection andmay be viewed as providing additional data-collection points while notsubstantially disturbing the regular instruction-count or cycle-countsampling described previously. These include execution of a RIEMITinstruction, which collects the value of a general register by storingit into the collection buffer 508. In addition, the data-collectioncontrol bits in the run-time instrumentation controls describedpreviously can be used to customize the types of data collected (e.g.,the E, C, R, and B control bits). In this manner, the type of datacollected is programmable.

In an embodiment, an instruction-data buffer is implemented to collectmodel dependent sample instruction data that is used to construct arun-time-instrumentation instruction record. The instruction-data buffercollects data from an instruction in anticipation of being availablewhen the instruction is identified as a sample instruction. In anembodiment, the instruction-data buffer is a hardware buffer/storagelocation in the processor where information about an instruction thatwould become a trigger as a sample point is saved, so that during thelog out process, it can be written out together with data from thecollection buffer 508. Similar to the collection buffer 508 it includesthe instruction address, and meta-data associated with that instruction.The metadata in the instruction-data buffer is often machine dependentand may include, but is not limited to: cache miss related information,and branch prediction related information.

In accordance with embodiments, other data collected may not be from thecollection buffer 508 and not from the instruction-data buffer. Examplesinclude data used to form parts of the following: (1) the first recordof a reporting group: timestamp or begin record; and (2) additionaltypes of records may be created for every reporting group and thus notstored in the collection buffer 508, such records, when present, may beplaced in the extra or machine-dependent section of a reporting group.These records are referred to herein as “system information records.”

FIG. 11 depicts a portion of an RICCB control block when MRIC is notpermitted to execute in semi-privileged mode (i.e., K bit is zero). Thecontrol block 1100 may include additional values other than thosedescribed in reference to FIG. 11. When the semi-privileged mode is notpermitted, the origin address section 1102 and the limit address section1104 are not used and the current values not modified by thelesser-privileged state program.

In an embodiment, only a subset of all of the run-time-instrumentationcontrol settings are updated by the successful execution of the MRICinstruction by the lesser-privileged state program.

When the RICCB is fetched, a number of errors may be encountered. Inaddition, if the address of the RICCB in the MRIC instruction is notaligned properly then an exception is encountered. Similarly, if theaddress in the MRIC instruction is inaccessible, either because of anerror state, or an invalid address, then an exception is encountered. Ifduring the execution of the MRIC instruction it is determined that theRICCB values conflict in any defined way (i.e. they are internallyinconsistent) an exception is also encountered.

In an embodiment, a special-operation exception is recognized for any ofthe following reasons: an MRIC instruction is issued andrun-time-instrumentation is enabled; the current run-time controls arenot valid; and/or the processor is in the lesser-privileged state andthe run-time-instrumentation stopped bit in the currentrun-time-instrumentation controls is zero.

In an embodiment, a specification exception is recognized for any of thefollowing reasons: the storage operand of MRIC is not aligned on adoubleword boundary; the processor is in the supervisor state or the Kbit in the current run-time-instrumentation controls is one and any ofthe following conditions is recognized: the specified limit address isless than the specified origin address; the specified current address isless than the specified origin address; and the specified currentaddress is greater than the sum of one plus the specified generatedlimit address; and the processor is in the lesser-privileged state, thek bit in the current RI controls is zero and any of the followingconditions is recognized: the specified current address is less than thecurrent origin address; the specified current address is greater thanthe sum of one plus the current limit address; an invalid mode isspecified.

In an embodiment, an MRIC instruction that is defined for a particularprocessor of one architecture may be executed by a second processor of adifferent architecture. In an embodiment, the second processoridentifies a software based emulation routine, and executes the MRICinstruction using the software based emulation routine.

FIG. 12 depicts a high-level example of a reporting group 1200 stored toprogram buffer 522 at a sample point. The size of a reporting group inrecords is represented by R_(RG), equals 2^((RGS+1)), where RGS is thereporting group size as an exponent. A model-dependent number of records(R_(NC)) copied from a location other than the collection buffer 508 mayor may not be copied non-destructively when used in a reporting group.In the example of FIG. 12, R_(RG)=8, R_(GS)=2, and R_(NC)=4. The examplereporting group 1200 shown in FIG. 12 includes a header section 1202, abody section 1204, an extra records section 1206, and a footer section1208.

The header section 1202 may include a begin record or a timestamp recordto hold status, tracking, and/or timing information. A begin record isstored in the header section 1202 for the first reporting group storedin a program buffer (i.e., when the RCA 1006 is equal to the ROA 1002).In an embodiment, the begin record includes a record type field of “02”,a number of reporting groups (NRG) field for indicating how manyreporting groups are currently stored in the program buffer, a RGS fieldto indicate the size of the reporting groups, a stopped (S) field forindicating whether or not the program buffer 522 is full, a halted (H)field for indicting whether the run-time instrumentation is halted, anda time of day (TOD) clock field for indicating when the begin record waswritten. In an embodiment, at least a subset of the fields in the beginrecord are sourced from the RI control block (e.g., RICCB). Anembodiment of the timestamp record has a record type of “03” andincludes a TOD clock field for indicating when the record was stored. Inan embodiment, a timestamp record is stored in the header section 1202for each reporting group other than the first reporting group.

The body section 1204 of the reporting group may include a variety ofrecords for events and information sampled from collection buffer 508.Events and information may represent, for example, state informationcaptured by an emit instruction, a transactional-execution abort, acall, a return, a branch, and filler.

In an embodiment, an emit record is created and stored in the collectionbuffer 508 upon a successful execution of a RIEMIT instruction. Anembodiment of the emit record includes a record type field of “10”, aninstruction address code field to indicate how the instruction addressbit positions of the current PSW are represented in the emit record, aninstruction address field which varies depending on the addressing mode(e.g., 64, 31 or 24 bit) and contains the instruction address of theRIEMIT instruction or execute type instruction if the RIEMIT was thetarget of an execute type instruction, and an emit data field forstoring the data from the general register specified by the RIEMITinstruction.

In an embodiment, a transactional execution mode abort record is createdand stored in the collection buffer 508 by either an implicit abort orby execution of a transaction abort instruction. An embodiment of theabort record includes a record type field of “11”, an instructionaddress code field to indicate how the instruction address bit positionsof the current PSW are represented in the transactional-execution abortrecord, an instruction address field which varies depending on theaddressing mode (e.g., 64, 31 or 24 bit) and contains the instructionaddress of the aborted instruction or execute type instruction if theaborted instruction was the target of an execute type instruction, and afield for any model dependent data associated with the abort.

In an embodiment, a call record is created by execution of a call typebranch instruction, such as: BRANCH AND SAVE (BASR) when the R2 field isnonzero, BRANCH AND SAVE (BAS), BRANCH RELATIVE AND SAVE LONG, BRANCHRELATIVE AND SAVE, BRANCH AND LINK (BALR) when the R2 field is nonzero,BRANCH AND LINK (BAL), and BRANCH AND SAVE AND SET MODE when the R2field is nonzero. An embodiment of the call record includes a recordtype field of “12”, an instruction address code field to indicate howthe instruction address bit positions of the current PSW are representedin the call record, an instruction address field which varies dependingon the addressing mode (e.g., 64, 31 or 24 bit) and contains the addressof the branch instruction or execute type instruction if the branchinstruction was the target of an execute type instruction, and a wellbehaved field for indicating whether or not the branch was correctlypredicted, and a target address field containing the branch targetaddress (also referred to as the “called location”).

Return records and transfer records may have the same format as the callrecords. In an embodiment, a return record has a record type field of“13” and is created by execution of a return type branch instructionsuch as a BRANCH ON CONDITION (BCR) when the R2 field is nonzero and themask is 15. For the return record, the instruction address fieldcontains the address of the branch instruction or execute typeinstruction if the branch is the target of an execute type instruction,and the target address field contains the return location.

In an embodiment, a transfer record has a record type field of “14” andis created by execution of a return type branch instruction such as: a.BRANCH ON CONDITION (BCR) when the R2 field is nonzero and the mask isin the range 1-14; b. BRANCH ON CONDITION (BC) when the J bit is zero orthe mask is in the range 1-14; c. BRANCH ON COUNT (BCT, BCTR, BCTG,BCTGR); d. BRANCH ON INDEX HIGH (BXH, BXHG); e. BRANCH ON INDEX LOW OREQUAL(BXLE, BXLEG); f. BRANCH RELATIVE ON CONDITION(BRC); g. BRANCHRELATIVE ON CONDITION LONG (BRCL); h. BRANCH RELATIVE ON COUNT (BRCT,BRCTG); i. BRANCH RELATIVE ON COUNT HIGH(BRCTH); j. BRANCH RELATIVE ONINDEX HIGH(BRXH, BRXHG); k. BRANCH RELATIVE ON INDEX LOW OR EQUAL(BRXLE, BRXLG); l. COMPARE AND BRANCH (CRB, CGRB); m. COMPARE AND BRANCHRELATIVE (CRJ, CGRJ); n. COMPARE IMMEDIATE AND BRANCH(CIB, CGIB); o.COMPARE IMMEDIATE AND BRANCH RELATIVE (CIJ, CGIJ); p. COMPARE LOGICALAND BRANCH(CLRB, CLGRB); q. COMPARE LOGICAL AND BRANCH RELATIVE(CLRJ,CLGRJ); r. COMPARE LOGICAL IMMEDIATE AND BRANCH (CLIB, CLGIB); and s.COMPARE LOGICAL IMMEDIATE AND BRANCH RELATIVE (CLIJ, CLGIJ). Thetransfer record is created when the branch is taken. For the transferrecord, the instruction address field contains the address of the branchinstruction or execute type instruction if the branch is the target ofan execute type instruction, and the target address field contains thereturn location.

A filler record is used in a reporting group when the number of validrecords in the collection buffer 508 is not sufficient to fill areporting group of the current RGS. An embodiment of a filler recordincludes record type field of “00” to indicate that the record is afiller record and the remaining bytes are undefined.

The extra records section 1206, when present, may containmodel-dependent records. In an embodiment, the format of an extra recordis similar to the filler record except for the record type is set to“01” to indicate that the record is an extra record and the remainingbytes of the extra record may contain model dependent data.

The footer section 1208 can include an instruction record containinginformation about execution of a sample instruction. An instructionrecord is created when a reporting group is stored for a sampleinstruction. An embodiment of the instruction record includes a recordtype field of “04”, an instruction address code field to indicate howthe instruction address bit positions of the current PSW are representedin the instruction record, an instruction address field which variesdepending on the addressing mode (e.g., 64, 31 or 24 bit) and containsthe instruction address of the sample instruction or execute typeinstruction if the sample instruction was the target of an execute typeinstruction, and an instruction-data buffer (IDB) field containing anymodel dependent data collected from the IDB.

As described above, embodiments can be embodied in the form ofcomputer-implemented processes and apparatuses for practicing thoseprocesses. An embodiment may include a computer program product 1300 asdepicted in FIG. 13 on a computer readable/usable medium 1302 withcomputer program code logic 1304 containing instructions embodied intangible media as an article of manufacture. Exemplary articles ofmanufacture for computer readable/usable medium 1302 may include floppydiskettes, CD-ROMs, hard drives, universal serial bus (USB) flashdrives, or any other computer-readable storage medium, wherein, when thecomputer program code logic 1304 is loaded into and executed by acomputer, the computer becomes an apparatus for practicing theinvention. Embodiments include computer program code logic 1304, forexample, whether stored in a storage medium, loaded into and/or executedby a computer, or transmitted over some transmission medium, such asover electrical wiring or cabling, through fiber optics, or viaelectromagnetic radiation, wherein, when the computer program code logic1304 is loaded into and executed by a computer, the computer becomes anapparatus for practicing the invention. When implemented on ageneral-purpose microprocessor, the computer program code logic 1304segments configure the microprocessor to create specific logic circuits.

Technical effects and benefits include an MRIC instruction that isexecutable by a lesser-privileged state program to modifyrun-time-instrumentation settings at runtime from the lesser-privilegedstate.

The terminology used herein is for the purpose of describing particularembodiments only and is not intended to be limiting of the invention. Asused herein, the singular forms “a”, “an” and “the” are intended toinclude the plural forms as well, unless the context clearly indicatesotherwise. It will be further understood that the terms “comprises”and/or “comprising,” when used in this specification, specify thepresence of stated features, integers, steps, operations, elements,and/or components, but do not preclude the presence or addition of oneor more other features, integers, steps, operations, elements,components, and/or groups thereof.

The corresponding structures, materials, acts, and equivalents of allmeans or step plus function elements in the claims below are intended toinclude any structure, material, or act for performing the function incombination with other claimed elements as specifically claimed. Thedescription of the present invention has been presented for purposes ofillustration and description, but is not intended to be exhaustive orlimited to the invention in the form disclosed. Many modifications andvariations will be apparent to those of ordinary skill in the artwithout departing from the scope and spirit of the invention. Theembodiment was chosen and described in order to best explain theprinciples of the invention and the practical application, and to enableothers of ordinary skill in the art to understand the invention forvarious embodiments with various modifications as are suited to theparticular use contemplated.

As will be appreciated by one skilled in the art, aspects of the presentinvention may be embodied as a system, method or computer programproduct. Accordingly, aspects of the present invention may take the formof an entirely hardware embodiment, an entirely software embodiment(including firmware, resident software, micro-code, etc.) or anembodiment combining software and hardware aspects that may allgenerally be referred to herein as a “circuit,” “module” or “system.”Furthermore, aspects of the present invention may take the form of acomputer program product embodied in one or more computer readablemedium(s) having computer readable program code embodied thereon.

Any combination of one or more computer readable medium(s) may beutilized. The computer readable medium may be a computer readable signalmedium or a computer readable storage medium. A computer readablestorage medium may be, for example, but not limited to, an electronic,magnetic, optical, electromagnetic, infrared, or semiconductor system,apparatus, or device, or any suitable combination of the foregoing. Morespecific examples (a non-exhaustive list) of the computer readablestorage medium would include the following: an electrical connectionhaving one or more wires, a portable computer diskette, a hard disk, arandom access memory (RAM), a read-only memory (ROM), an erasableprogrammable read-only memory (EPROM or Flash memory), an optical fiber,a portable compact disc read-only memory (CD-ROM), an optical storagedevice, a magnetic storage device, or any suitable combination of theforegoing. In the context of this document, a computer readable storagemedium may be any tangible medium that can contain, or store a programfor use by or in connection with an instruction execution system,apparatus, or device.

A computer readable signal medium may include a propagated data signalwith computer readable program code embodied therein, for example, inbaseband or as part of a carrier wave. Such a propagated signal may takeany of a variety of forms, including, but not limited to,electro-magnetic, optical, or any suitable combination thereof. Acomputer readable signal medium may be any computer readable medium thatis not a computer readable storage medium and that can communicate,propagate, or transport a program for use by or in connection with aninstruction execution system, apparatus, or device.

Program code embodied on a computer readable medium may be transmittedusing any appropriate medium, including but not limited to wireless,wireline, optical fiber cable, RF, etc., or any suitable combination ofthe foregoing.

Computer program code for carrying out operations for aspects of thepresent invention may be written in any combination of one or moreprogramming languages, including an object oriented programming languagesuch as Java, Smalltalk, C++ or the like and conventional proceduralprogramming languages, such as the “C” programming language or similarprogramming languages. The program code may execute entirely on theuser's computer, partly on the user's computer, as a stand-alonesoftware package, partly on the user's computer and partly on a remotecomputer or entirely on the remote computer or server. In the latterscenario, the remote computer may be connected to the user's computerthrough any type of network, including a local area network (LAN) or awide area network (WAN), or the connection may be made to an externalcomputer (for example, through the Internet using an Internet ServiceProvider).

Aspects of the present invention are described above with reference toflowchart illustrations and/or schematic diagrams of methods, apparatus(systems) and computer program products according to embodiments of theinvention. It will be understood that each block of the flowchartillustrations and/or block diagrams, and combinations of blocks in theflowchart illustrations and/or block diagrams, can be implemented bycomputer program instructions. These computer program instructions maybe provided to a processor of a general purpose computer, specialpurpose computer, or other programmable data processing apparatus toproduce a machine, such that the instructions, which execute via theprocessor of the computer or other programmable data processingapparatus, create means for implementing the functions/acts specified inthe flowchart and/or block diagram block or blocks.

These computer program instructions may also be stored in a computerreadable medium that can direct a computer, other programmable dataprocessing apparatus, or other devices to function in a particularmanner, such that the instructions stored in the computer readablemedium produce an article of manufacture including instructions whichimplement the function/act specified in the flowchart and/or blockdiagram block or blocks.

The computer program instructions may also be loaded onto a computer,other programmable data processing apparatus, or other devices to causea series of operational steps to be performed on the computer, otherprogrammable apparatus or other devices to produce a computerimplemented process such that the instructions which execute on thecomputer or other programmable apparatus provide processes forimplementing the functions/acts specified in the flowchart and/or blockdiagram block or blocks.

As described above, embodiments can be embodied in the form ofcomputer-implemented processes and apparatuses for practicing thoseprocesses. In embodiments, the invention is embodied in computer programcode executed by one or more network elements. Embodiments include acomputer program product on a computer usable medium with computerprogram code logic containing instructions embodied in tangible media asan article of manufacture. Exemplary articles of manufacture forcomputer usable medium may include floppy diskettes, CD-ROMs, harddrives, universal serial bus (USB) flash drives, or any othercomputer-readable storage medium, wherein, when the computer programcode logic is loaded into and executed by a computer, the computerbecomes an apparatus for practicing the invention. Embodiments includecomputer program code logic, for example, whether stored in a storagemedium, loaded into and/or executed by a computer, or transmitted oversome transmission medium, such as over electrical wiring or cabling,through fiber optics, or via electromagnetic radiation, wherein, whenthe computer program code logic is loaded into and executed by acomputer, the computer becomes an apparatus for practicing theinvention. When implemented on a general-purpose microprocessor, thecomputer program code logic segments configure the microprocessor tocreate specific logic circuits.

The flowchart and block diagrams in the Figures illustrate thearchitecture, functionality, and operation of possible implementationsof systems, methods, and computer program products according to variousembodiments of the present invention. In this regard, each block in theflowchart or block diagrams may represent a module, segment, or portionof code, which comprises one or more executable instructions forimplementing the specified logical function(s). It should also be notedthat, in some alternative implementations, the functions noted in theblock may occur out of the order noted in the figures. For example, twoblocks shown in succession may, in fact, be executed substantiallyconcurrently, or the blocks may sometimes be executed in the reverseorder, depending upon the functionality involved. It will also be notedthat each block of the block diagrams and/or flowchart illustration, andcombinations of blocks in the block diagrams and/or flowchartillustration, can be implemented by special purpose hardware-basedsystems that perform the specified functions or acts, or combinations ofspecial purpose hardware and computer instructions.

1. A computer program product for executing a modify runtime instructioncontrols (MRIC) instruction, the MRIC instruction executable in either asupervisor state or a lesser-privileged state, the MRIC instruction forsetting only a subset of run-time-instrumentation controls, wherein allof said run-time-instrumentation controls are loadable by a privilegedload run-time-instrumentation controls (LRIC) instruction, the computerprogram product comprising: a tangible storage medium readable by aprocessing circuit and storing instructions for execution by theprocessing circuit for performing a method comprising: fetching the MRICinstruction, the MRIC instruction including an address of arun-time-instrumentation control block (RICCB); fetching, by aprocessor, the RICCB, the RICCB including a plurality of values formodifying said subset of run-time-instrumentation controls of theprocessor, the subset of run-time-instrumentation controls comprising aruntime instrumentation program buffer current address (RCA) of aruntime instrumentation program buffer (RIB) location, the RIB forholding runtime instrumentation information of events recognized by theprocessor during program execution; loading the plurality of values intothe run-time-instrumentation controls; and using the loaded plurality ofvalues to provide run-time-instrumentation event information to the RIB.2. The computer program product according to claim 1, furthercomprising: deriving a model dependent limited value for at least one ofthe plurality of values of the RICCB; and loading the model dependentlimited value as an updated value into the run-time-instrumentationcontrols.
 3. The computer program product according to claim 2, whereina reporting group size causes the model dependent limited value to beloaded, further comprising: based on a K field of therun-time-instrumentation controls having a first value, setting acurrent address to a value of an origin address of the RICCB; and basedon the K field of the run-time-instrumentation controls having a secondvalue, setting the current address to a value of a specified RICCBcurrent address value.
 4. The computer program product according toclaim 1, further comprising causing an exception, based on any one ormore of: determining that the address in the MRIC instruction does notalign with a double word boundary; and determining that the RICCB cannotbe fetched from the address included in the MRIC instruction.
 5. Thecomputer program product according to claim 1, further comprising:determining that one or more values in the RICCB are valid, wherein thedetermining further comprises any one of: determining that arun-time-instrumentation S bit indicates that execution of the MRICinstruction from the lesser-privileged state is not permitted;determining that the run-time-instrumentation controls are not valid;and determining that run-time-instrumentation is not enabled.
 6. Thecomputer program product according to claim 1, wherein the plurality ofvalues of the RICCB further include one or more of: a control to managedetails of run-time-instrumentation data sampling; a control to managedetails of run-time-instrumentation data collection; a control to managedetails of run-time-instrumentation data reporting into a programbuffer; a control to manage detection of instruction-cache misses; acontrol to manage detection of data-cache misses; a control to manage asize of a reporting group; a control to manage a current address withinan output program buffer at which a next reporting group is stored;controls to manage data collection of data on call-type, return-type,and transfer-type branches; and controls to manage data collection ofbranches that are correctly or incorrectly predicted and taken or nottaken.
 7. The computer program product according to claim 1, wherein theMRIC instruction is defined for a first computer architecture, and thefetching and parsing is executed by a second processor of an alternatecomputer architecture, the fetching and parsing by the second processorcomprising: identifying a software routine for emulating execution ofthe MRIC instruction on the first computer architecture; and executingthe MRIC instruction with the software routine.
 8. The computer programproduct according to claim 1, wherein no values in therun-time-instrumentation controls are updated if an error isencountered. 9-16. (canceled)
 17. A computer system for executing amodifying run-time-instrumentation controls (MRIC) instruction fromeither a supervisor state or a lesser-privileged state, the MRICinstruction for setting only a subset of run-time-instrumentationcontrols, wherein all of said run-time-instrumentation controls areloadable by a privileged load run-time-instrumentation controls (LRIC)instruction comprising: a computer processor comprising arun-time-instrumentation module, the run-time-instrumentation moduleconfigured to perform a method comprising: fetching the MRICinstruction, the MRIC instruction including an address of arun-time-instrumentation control block (RICCB); fetching the RICCB, theRICCB including a plurality of values for modifying said subset ofrun-time-instrumentation controls of the computer processor, the subsetof run-time-instrumentation controls comprising a runtimeinstrumentation program buffer current address (RCA) of a runtimeinstrumentation program buffer (RIB) location, the RIB for holdingruntime instrumentation information of events recognized by the computerprocessor during program execution; loading the plurality of values intothe run-time-instrumentation controls; and using the loaded plurality ofvalues to provide run-time-instrumentation event information to the RIB.18. The system according to claim 17, further comprising: deriving amodel dependent limited value for at least one of the plurality ofvalues of the RICCB; and loading the model dependent limited value as anupdated value into the run-time-instrumentation controls.
 19. The systemaccording to claim 18, wherein a reporting group size causes the modeldependent limited value to be loaded, further comprising: based on a Kfield of the run-time-instrumentation controls having a first value,setting a current address to a value of an origin address of the RICCB;and based on the K field of the run-time-instrumentation controls havinga second value, setting the current address to a value of a specifiedRICCB current address value.
 20. The system according to claim 17,further comprising causing an exception, based on any one or more of:determining that the address in the MRIC instruction does not align witha double word boundary; and determining that the RICCB cannot be fetchedfrom the address included in the MRIC instruction.
 21. The systemaccording to claim 17, further comprising: determining that one or morevalues in the RICCB are valid, wherein the determining further comprisesany one of: determining that a run-time-instrumentation S bit indicatesthat execution of the MRIC instruction from the lesser-privileged stateis not permitted; determining that the run-time-instrumentation controlsare not valid; and determining that run-time-instrumentation is notenabled.
 22. The system according to claim 17, wherein the plurality ofvalues of the RICCB further include one or more of: a control to managedetails of run-time-instrumentation data sampling; a control to managedetails of run-time-instrumentation data collection; a control to managedetails of run-time-instrumentation data reporting into a programbuffer; a control to manage detection of instruction-cache misses; acontrol to manage detection of data-cache misses; a control to manage asize of a reporting group; a control to manage a current address withinan output program buffer at which a next reporting group is stored;controls to manage data collection of data on call-type, return-type,and transfer-type branches; and controls to manage data collection ofbranches that are correctly or incorrectly predicted and taken or nottaken.
 23. The system according to claim 17, wherein the MRICinstruction is defined for a first computer architecture, and thefetching and parsing is executed by a second processor of an alternatecomputer architecture, the fetching and parsing by the second processorcomprising: identifying a software routine for emulating execution ofthe MRIC instruction on the first computer architecture; and executingthe MRIC instruction with the software routine.
 24. The system accordingto claim 17, wherein no values in the run-time-instrumentation controlsare updated if an error is encountered.